<template>
  <a-row gutter="16">
    <a-col :span="6">
      <a-descriptions size="small" :column="1" bordered>
        <a-descriptions-item label="本地104主站服务端口">
          <a-input v-model:value="registerConfig.port104"></a-input>
        </a-descriptions-item>
        <a-descriptions-item label="转发模式">
          <a-select v-model:value="registerConfig.forwardMode104" :options="modeList" style="width: 100%;"></a-select>
        </a-descriptions-item>
        <a-descriptions-item label="遥测增值" v-if="registerConfig.forwardMode104=='THREE'">
          <a-input v-model:value="registerConfig.threeAdd104"></a-input>
        </a-descriptions-item>
        <a-descriptions-item label="遥信增值" v-if="registerConfig.forwardMode104=='THREE'">
          <a-input v-model:value="registerConfig.threeSwitchAdd104"></a-input>
        </a-descriptions-item>
        <a-descriptions-item label="转发遥测测点数量">
          <a-input v-model:value="registerConfig.serverPointCount"></a-input>
        </a-descriptions-item>
        <a-descriptions-item label="转发遥信测点数量">
          <a-input v-model:value="registerConfig.serverSwitchPointCount"></a-input>
        </a-descriptions-item>
      </a-descriptions>

      <a-card size="small" :bordered="false" >
        <a-flex justify="end">
          <a-button type="primary" ghost @click="save"> 保存</a-button>
        </a-flex>
      </a-card>
    </a-col>
  </a-row>
</template>
<script setup>

import {ref} from "vue";
import {baseRequest} from "@/utils/request.js";
import {message} from "ant-design-vue";

const registerConfig = ref({})
const modeList = ref([
  {
    label:"分站转发",
    value:"ONE",
  },
  {
    label:"合并转发",
    value:"TWO",
  },
  {
    label:"合并增值",
    value:"THREE",
  }
])
baseRequest("/config/get/control", {}).then(res => {
  registerConfig.value.port104 = res.data.data.port104
  registerConfig.value.forwardMode104 = res.data.data.forwardMode104
  registerConfig.value.threeAdd104 = res.data.data.threeAdd104
  registerConfig.value.threeSwitchAdd104 = res.data.data.threeSwitchAdd104
  registerConfig.value.serverPointCount = res.data.data.serverPointCount
  registerConfig.value.serverSwitchPointCount = res.data.data.serverSwitchPointCount
})
const save = () => {
  baseRequest("/config/set/control", registerConfig.value, 'post').then(res => {
    if (res.data.code == 200) {
      message.success("保存成功，重启服务后生效")
    } else {
      message.error(res.data.message)
    }
  })
}
</script>

<style scoped>

</style>
